package net.anzhuo.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import net.anzhuo.common.entity.PaginationVO;
import net.anzhuo.common.enums.ResultEnum;
import net.anzhuo.common.utils.ExceptionUtil;
import net.anzhuo.dao.GsPenaltyCreditChinaMapper;
import net.anzhuo.entity.GsPenaltyCreditChina;
import net.anzhuo.service.GsPenaltyCreditChinaService;
@Service
public class GsPenaltyCreditChinaServiceImpl implements GsPenaltyCreditChinaService {

	@Autowired
	private GsPenaltyCreditChinaMapper gsPenaltyCreditChinaMapper;
	
	@Override
	public GsPenaltyCreditChina getById(Long id) {
		// TODO Auto-generated method stub
		
		return gsPenaltyCreditChinaMapper.getById(id);
	}

	@Override
	public List<GsPenaltyCreditChina> getBycoMd5(String coMd5) {
		// TODO Auto-generated method stub
		return gsPenaltyCreditChinaMapper.getBycoMd5(coMd5);
	}

	@Override
	public PaginationVO<GsPenaltyCreditChina> getListWithPage(GsPenaltyCreditChina gsPenaltyCreditChina) {
		PaginationVO<GsPenaltyCreditChina> paginationVO = new PaginationVO<>();
		paginationVO.setList(gsPenaltyCreditChinaMapper.getListWithPage(gsPenaltyCreditChina));
		paginationVO.setTotalCount(gsPenaltyCreditChinaMapper.getCount(gsPenaltyCreditChina));
		paginationVO.setTotalPage((gsPenaltyCreditChinaMapper.getCount(gsPenaltyCreditChina) + gsPenaltyCreditChina.getPageSize() -1)  / gsPenaltyCreditChina.getPageSize());
		paginationVO.setPageNo(gsPenaltyCreditChina.getPageNo());
		return paginationVO;
	}

	@Override
	public List<GsPenaltyCreditChina> getList() {
		// TODO Auto-generated method stub
		return  gsPenaltyCreditChinaMapper.getList();
	}

	@Override
	public List<GsPenaltyCreditChina> getList(GsPenaltyCreditChina gsPenaltyCreditChina) {
		// TODO Auto-generated method stub
		return gsPenaltyCreditChinaMapper.getListByQuery(gsPenaltyCreditChina);
	}

	@Override
	@Transactional(rollbackFor=Throwable.class)
	public void update(GsPenaltyCreditChina gsPenaltyCreditChina) {
		// TODO Auto-generated method stub
		gsPenaltyCreditChinaMapper.update(gsPenaltyCreditChina);

	}

	@Override
	@Transactional(rollbackFor=Throwable.class)
	public void save(GsPenaltyCreditChina gsPenaltyCreditChina) {
		// TODO Auto-generated method stub
		gsPenaltyCreditChinaMapper.save(gsPenaltyCreditChina);
	}

	@Override
	@Transactional(rollbackFor=Throwable.class)
	public void delete(Long id) {
		GsPenaltyCreditChina gsPenaltyCreditChina = gsPenaltyCreditChinaMapper.getById(id);
		if (gsPenaltyCreditChina == null) {
			ExceptionUtil.throwAppException(ResultEnum.ILLEGAL_OPERATION);
			return;
		}
		gsPenaltyCreditChinaMapper.update(gsPenaltyCreditChina);

	}

}
